//
//  CommonClassReportSectionHeadView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2018/1/29.
//  Copyright © 2018年 zongquankeji. All rights reserved.
//

#import "CommonClassReportSectionHeadView.h"

@implementation CommonClassReportSectionHeadView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
        
        //背景色
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = BackGroundColor;
        [self addSubview:lineView];
        self.lineView = lineView;
        
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = @"报表明细";
        titleLabel.font = MidBigFont;
        titleLabel.textColor = CSColorFromRGB(0x666666);
        [self.lineView addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        UIImageView *lineView2 = [[UIImageView alloc] init];
        lineView2.image = [UIImage imageNamed:@"line"];
        [self.lineView addSubview:lineView2];
        self.lineView2 = lineView2;
        
        /**
         头像，姓名，性别，电话
         */
        UIImageView *icon = [[UIImageView alloc] init];
        icon.layer.cornerRadius = 30;
        icon.clipsToBounds = YES;
        icon.image = PlaceHold;
        [self addSubview:icon];
        self.iconImage = icon;
        
        UILabel *name = [[UILabel alloc] init];
        name.text = @"姓名";
        name.font = MidBigFont;
        name.textColor = CSBlackColor;
        [self addSubview:name];
        self.nameLabel = name;
        
        UIImageView *sex = [[UIImageView alloc] init];
        sex.image = [UIImage imageNamed:@"icon_man"];
        [self addSubview:sex];
        self.sexImage = sex;
        
        UILabel *tel = [[UILabel alloc] init];
        tel.text = @"18179402031";
        tel.font = MidFont;
        tel.textColor = CSColorFromRGB(0x666666);
        [self addSubview:tel];
        self.telLabel = tel;
        
        /**
         背景色1,团课，未完成。
         */
        UIView *lineView1 = [[UIView alloc] init];
        lineView1.backgroundColor = BackGroundColor;
        [self addSubview:lineView1];
        self.lineView1 = lineView1;
        
        /**
         团课（节）
         */
        UILabel *receiveLabel1 = [[UILabel alloc] init];
        receiveLabel1.text = @"22";
        receiveLabel1.font = MidBigFont;
        receiveLabel1.textColor = CSColorFromRGB(0x666666);
        receiveLabel1.textAlignment = NSTextAlignmentCenter;
        [self.lineView1 addSubview:receiveLabel1];
        self.classLabel1 = receiveLabel1;
        
        /**
         团课（节）
         */
        UILabel *receiveLabel = [[UILabel alloc] init];
        receiveLabel.text = @"团课(节)";
        receiveLabel.font = MidFont;
        receiveLabel.textColor = CSColorFromRGB(0x666666);
        receiveLabel.textAlignment = NSTextAlignmentCenter;
        [self.lineView1 addSubview:receiveLabel];
        self.classLabel = receiveLabel;
        
        /**
         未完成（节）
         */
        UILabel *noClass1 = [[UILabel alloc] init];
        noClass1.text = @"22";
        noClass1.font = MidBigFont;
        noClass1.textColor = CSColorFromRGB(0x666666);
        noClass1.textAlignment = NSTextAlignmentCenter;
        [self.lineView1 addSubview:noClass1];
        self.noClassLabel1 = noClass1;
        
        /**
         未完成（节）
         */
        UILabel *noClass = [[UILabel alloc] init];
        noClass.text = @"未完成(节)";
        noClass.font = MidFont;
        noClass.textColor = CSColorFromRGB(0x666666);
        noClass.textAlignment = NSTextAlignmentCenter;
        [self.lineView1 addSubview:noClass];
        self.noClassLabel = noClass;
        
        /**
         时间
         */
        UILabel *typeLabel = [[UILabel alloc] init];
        typeLabel.font = MidBigFont;
        typeLabel.textColor = CSColorFromRGB(0x666666);
        typeLabel.textAlignment = NSTextAlignmentCenter;
        typeLabel.text = @"时间";
        [self addSubview:typeLabel];
        self.typeLabel = typeLabel;
        
        /**
         课程
         */
        UILabel *countLabel = [[UILabel alloc] init];
        countLabel.text = @"课程";
        countLabel.font = MidBigFont;
        countLabel.textColor = CSColorFromRGB(0x666666);
        countLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:countLabel];
        self.countLabel = countLabel;
        
        /**
         类型
         */
        UILabel *netReceiptLabel = [[UILabel alloc] init];
        netReceiptLabel.text = @"类型";
        netReceiptLabel.font = MidBigFont;
        netReceiptLabel.textColor = CSColorFromRGB(0x666666);
        netReceiptLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:netReceiptLabel];
        self.netReceiptLabel = netReceiptLabel;
        
        /**
         是否完成
         */
        UILabel *receiveLabel2 = [[UILabel alloc] init];
        receiveLabel2.text = @"是否完成";
        receiveLabel2.font = MidBigFont;
        receiveLabel2.textColor = CSColorFromRGB(0x666666);
        receiveLabel2.textAlignment = NSTextAlignmentCenter;
        [self addSubview:receiveLabel2];
        self.receiveLabel = receiveLabel2;
        
        
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    /**
     报表明细
     */
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.width.top.mas_equalTo(self);
        
        make.height.mas_equalTo(40);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.lineView);
        
        make.top.bottom.mas_equalTo(self.lineView);
        
        
        
    }];
    
    [self.lineView2 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.center.mas_equalTo(self.titleLabel);
        
        make.height.mas_equalTo(1);
    }];
    
    /**
     头像，姓名，性别，电话
     */
    [self.iconImage mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self);
        
        make.top.mas_equalTo(self.lineView.mas_bottom).offset(15);
        
        make.width.height.mas_equalTo(60);
        
    }];
    
    [self.nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self.iconImage.mas_centerX);
        
        make.top.mas_equalTo(self.iconImage.mas_bottom).offset(15);
        
    }];
    
    [self.sexImage mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.iconImage.mas_centerX);
        
        make.centerY.mas_equalTo(self.nameLabel);
        
    }];
    
    [self.telLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(10);
        
        make.centerX.mas_equalTo(self.iconImage);
        
    }];
    
    /**
     背景色1,团课，未完成。
     */
    
    [self.lineView1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.telLabel.mas_bottom).offset(10);
        
        make.left.width.mas_equalTo(self);
        
        make.height.mas_equalTo(60);
        
    }];
    
    [self.classLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.lineView1).offset(10);
        make.left.mas_equalTo(self.lineView1);
//        make.bottom.mas_equalTo(self.classLabel.mas_top);
//        make.height.mas_equalTo(20);
        
        
    }];
    
    [self.noClassLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.classLabel1.mas_right);
        
        make.right.mas_equalTo(self.lineView1);
        
        make.top.height.width.mas_equalTo(self.classLabel1);
    }];
    
    [self.classLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
//        make.height.mas_equalTo(20);
        make.left.mas_equalTo(self.lineView1);
        make.bottom.mas_equalTo(self.lineView1.mas_bottom).offset(-10);
        make.top.mas_equalTo(self.classLabel1.mas_bottom);
        
        
    }];
    
    [self.noClassLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self.lineView1);
        
        make.left.mas_equalTo(self.classLabel.mas_right);
        
        make.top.height.width.mas_equalTo(self.classLabel);
    }];
    
    
    
    /**
     类型Label
     */
    [self.typeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self);
        
        make.top.mas_equalTo(self.lineView1.mas_bottom).offset(10);
        
        make.bottom.mas_equalTo(self).offset(-10);
    }];
    
    [self.countLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.typeLabel.mas_right);
        
        make.top.height.width.mas_equalTo(self.typeLabel);
    }];
    
    /**
     应收
     */
    [self.netReceiptLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.countLabel.mas_right);
        
        make.top.height.width.mas_equalTo(self.typeLabel);
        
    }];
    
    /**
     实收
     */
    [self.receiveLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.netReceiptLabel.mas_right);
        
        make.top.height.width.mas_equalTo(self.typeLabel);
        
        make.right.mas_equalTo(self);
    }];
}

@end
